<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户自有车辆列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var prjId='${prjId}';
	var cstType='${cstType}';
	var cstId = '${cstId}';
	var detailFlag = '${detailFlag}';
	var grid = null;
	$(function () {
		initGrid();//grid
		if(detailFlag=="true"){
			$("#addBtn").hide();
			$("#removeBtn").hide();
		}
	});
	
	//初始化列表
	function initGrid(){
		var params = {};
		params.prjId = prjId;
		params.cstId = cstId;
		$("#grid").ligerGrid({
	    	url: '<%=path%>/project/prjcstownvehicle/initList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	            { display: '购买时间', name: 'buyDt', minWidth: 100 ,render:renderDate,enabledSort:true},
	            { display: '品牌', name: 'brNm', minWidth: 140, },
	            { display: '数量', name: 'qty', minWidth: 140 , enabledSort:true},
	            { display: '购买价格（万元）', name: 'buyPrc', minWidth: 140 , enabledSort:true},
	            { display: '贷款余额（万元）', name: 'loanBlc', minWidth: 60, enabledSort:true },
	            { display: '运载吨位', name: 'cryTng', minWidth: 60, enabledSort:true },
	            { display: '客车载客数（仅客车）', name: 'psgNum', minWidth: 60, enabledSort:true },
	            {
	                display: '操作',
	                isSort: false,
	                width: 150,
	                render: function (rowdata, rowindex, value){
	                	 var h="";
	                	 if(detailFlag=="false"){
	                        h+='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
	                        h+="'"+rowdata.id+"'";
	                        h+=')"><i class="sqBtnIco_4"></i>修改</a>'
	               		 }
	                        h+='<a class="sq-button-hasicon" href="javascript:detailBtn(';
	                        h+="'"+rowdata.id+"'";
	                        h+=')">详细</a>'
	                    return h;
	                }
	            }
	        ],
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        allowUnSelectRow: true,
            alternatingRow: false,
	        rownumbers:true,
	        usePagerOnLessPagesize: true,
	    });
		grid = liger.get("grid");
		grid.setHeight(500);
	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	//添加
	function addBtn(){
  		var win = $.ligerDialog.open({ title:'添加客户自有车辆信息', height: 300,width: 750, url: '<%=path%>/project/prjcstownvehicle/toAddPage.do?cstType='+cstType+'&&cstId='+cstId+'&&prjId='+prjId, isResize: true });
	}

	//修改
	function modifyBtn(id){
  		var win = $.ligerDialog.open({title:'修改客户自有车辆信息',  height: 300,width: 750, url: '<%=path%>/project/prjcstownvehicle/toAddPage.do?id='+id+'&&cstId='+cstId+'&&prjId='+prjId, isResize: true });
	}
	
	//查看
	function detailBtn(id){
  		var win = $.ligerDialog.open({title:'查看客户自有车辆信息',height: 300,width: 750, url: '<%=path%>/project/prjcstownvehicle/toDetailPage.do?id='+id+'&&cstId='+cstId+'&&prjId='+prjId, isResize: true });
	}
	
	
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//删除所选信息
	function removeBtn(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length <1){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
			return;
		}
		var _ids = [];
		for ( var index in selectedRows) {
			_ids.push(selectedRows[index].id);
		}
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/prjcstownvehicle/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}
</script>

<body class="iframeBody">
	<div class="Wrapper">
	  <div class="pageIn2layout">
	<jsp:include page="../../project/prjbscinfo/prjInvestRpt.jsp" flush="true" >
			<jsp:param name="currentNav" value="prjcstownvehicle"/>
	</jsp:include>
	<div class="pageIn2L_mid">
        <div>
           <div id="pageInTab" class="pageInTab">
           <div class="clearFix"></div>
<div class="btnsBox">
         <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">新增</span>
  		 <span id="removeBtn" onclick="removeBtn();" class="sq-button sq-button-round">作废</span>
     <!--   <span id="modifyBtn" onclick="modifyBtn();" class="sq-button sq-button-hasicon"><i class="sqBtnIco_4"></i>修改</span>
        <span id="detailBtn" onclick="detailBtn();" class="sq-button sq-button-hasicon"><i class="sqBtnIco_2"></i>详细</span> -->
  </div>
<div id="grid" class="sq-grid"></div>
</div>
	</div>
</div>
</div>
</div>
</body>
</html>